from django.db import models
import datetime

# Create your models here.
class Location(models.Model):
	location_name = models.CharField(maxlength=100)
	location_description = models.TextField(blank=True)
	location_created = models.DateTimeField(editable=False)
	location_modified = models.DateTimeField(editable=False)
	location_slug = models.SlugField(prepopulate_from=("location_name",))
	
	def save(self):
		if not self.id:
			self.location_created = datetime.date.today()
		self.location_modified = datetime.datetime.today()
		super(Location, self).save()
		
	def get_absolute_url(self):
		return "/%s/" % self.locaion_slug
	
	def __str__(self):
		return self.location_name
	
	class Admin:
		pass
		list_display = ('location_name', 'location_description')
		search_fields = ['location_name', 'location_description']